﻿/************************************************************************

   Extended Silverlight Toolkit

   Copyright (C) 2010-2012 Xceed Software Inc.

   This program is provided to you under the terms of the Microsoft Public
   License (Ms-PL) as published at http://extendedsilverlight.codeplex.com/license

   Please purchase a commercial version of this toolkit if you are using
   it in a commercial product. The commercial versions support the project,
   and also include more features for each control, priority support,
   source code, updates, removed watermark, and a proprietary license.

   Visit http://xceed.com and follow @datagrid on Twitter.

  **********************************************************************/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using Xceed.Silverlight.Data;
using Xceed.Silverlight.Data.Stats;

namespace Xceed.Silverlight.DataGrid
{
  public class EmptyDataSourceProvider : SyncDataSourceProvider
  {
    public EmptyDataSourceProvider()
    {
    }

    #region ElementType Property

    protected internal override Type ElementType
    {
      get
      {
        return typeof( object );
      }
    }

    #endregion

    #region CanJumpToItem Property

    public override bool CanJumpToItem
    {
      get
      {
        return true;
      }
    }

    #endregion

    #region CanJump Property

    public override bool CanJump
    {
      get
      {
        return true;
      }
    }

    #endregion

    #region CanCalculateStats Property

    public override bool CanCalculateStats
    {
      get
      {
        return true;
      }
    }

    #endregion

    #region CanFilterPredicate Internal Property

    internal override bool CanFilterPredicate
    {
      get
      {
        return true;
      }
    }

    #endregion

    #region CanJumpToDeletedItem Internal Property

    internal override bool CanJumpToDeletedItem
    {
      get
      {
        return true;
      }
    }

    #endregion

    #region CanFilter Property

    public override bool CanFilter
    {
      get
      {
        return false;
      }
    }

    #endregion

    #region IsPrimaryKeyVolatile Internal Property

    internal override bool IsPrimaryKeyVolatile
    {
      get
      {
        return false;
      }
    }

    #endregion

    protected override IEnumerable<Type> GetSupportedStatFunctions( Type dataType )
    {
      yield return typeof( StatFunction );
    }

    protected override IEnumerable<SortDescription> GetPrimaryKeyInfo()
    {
      yield return new SortDescription( "#@@_EMPTY_KEY_@@#", ListSortDirection.Ascending );
    }

    protected override CountQueryResult ExecuteCountQuery( CountQueryParameters queryParameters )
    {
      return new CountQueryResult( 0 );
    }

    protected override DataQueryResult ExecuteDataQuery( DataQueryParameters queryParameters )
    {
      return new DataQueryResult( Enumerable.Empty<object>(), 0, 0 );
    }

    protected override GroupCountQueryResult ExecuteGroupCountQuery( GroupCountQueryParameters queryParameters )
    {
      int groupCountDepth = queryParameters.Sort.SortDescriptions.Count;
      return new GroupCountQueryResult( Enumerable.Repeat<long>( 0, groupCountDepth ) );
    }

    protected override StatQueryResult ExecuteStatQuery( StatQueryParameters queryParameters )
    {
      return new StatQueryResult( new StatResult( 0 ) );
    }

    internal override bool FindElementMemberType( string memberName, out Type type )
    {
      type = typeof(string);
      return true;
    }
  }
}
